<template>
  <div class="index-container">
    <RayTable ref="table" :menu="menu" :data_object_no="menu.data_object_no" :height="tableHeight">
      <template #line_btn_append="{row}">
        <el-button type="primary" @click="scan(row)">查看报表</el-button>
      </template>
    </RayTable>
    <el-dialog :title="form.name" :visible.sync="dialogScanVisible" width="600px">
      <el-form :model="form" size="mini" label-width="80px">
        <el-form-item v-for="(item,index) in where" :key="index" :label="item.split('|')[0]">
          <el-input v-if="item.split('|')[1]!='date'" v-model="select_where[index]" autocomplete="off"></el-input>
          <el-date-picker v-if="item.split('|')[1]=='date'" v-model="select_where[index]" value-format="yyyy-MM-dd"
            type="date" placeholder="选择日期" style="width:100%"></el-date-picker>
        </el-form-item>
      </el-form>
      <div style="color:red;width:80px;text-align:right;float:left">注释：</div>
      <div style="margin-left: 80px">{{form.note}}</div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogScanVisible = false">取 消</el-button>
        <el-button type="primary" @click="scanConfirm">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import RayTable from '@/views/template/components/rayTable.vue';

  export default {
    name: 'ReportList',
    components: {
      RayTable
    },
    data() {
      return {
        where: [],
        select_where: [],
        form: {},
        dialogScanVisible: false
      };
    },
    watch: {},
    created() {
      this.menu = this.$route.meta.query;
      this.tableHeight = document.documentElement.clientHeight - 250;
    },
    methods: {
      scan(row) {
        this.form = row;
        if (this.form.r_where != null && this.form.r_where != '') {
          this.where = this.form.r_where.split(",");
          this.dialogScanVisible = true;
        } else {
          this.scanConfirm();
        }

      },
      scanConfirm() {
        this.dialogScanVisible = false
        this.$router.replace({
          path: '/redirect/reportscan',
          query: {
            params: this.select_where,
            id: this.form.id
          }
        })
      }
    }
  };
</script>

<style></style>
